import java.util.Calendar;



public class MidiIn 
{
	public void newNote(int pitch, int velocity, long onset){
		Main.onsets = AltMath.incArray(Main.onsets);
		Main.onsets[Main.onsets.length-1] = (int)(onset);
		Object[] oscArray = new Object[] {pitch};
		OSC.main(oscArray,"/note-in");
		if (!Main.stillPlaying)
		{
			Main.stillPlaying=true;
			oscArray = new Object[] {"BOBBING", 1};
			OSC.main(oscArray,"/head-commands");
		}
		if (velocity>0){

			long timeDiff = (onset - Main.lastTimeStamp);
			Main.lastTimeStamp = onset;	
			Main.improvise.lastInputOnset=Calendar.getInstance().getTimeInMillis();

			int[] note = {pitch-24,velocity, (int) timeDiff};

			Main.improvise.incomingNote(pitch);
			System.out.println("note in: "+pitch);
			Main.notesArray[Main.notesArrayPointer][0]=note[0];
			Main.notesArray[Main.notesArrayPointer][1]=note[1];
			Main.notesArray[Main.notesArrayPointer][2]=note[2];
			Main.notesArrayPointer=Main.notesArrayPointer+1;
			
			if (Main.learning)
			{
				Main.learnArrayTemp[Main.learnArrayPointerTemp][0]=note[0];
				Main.learnArrayTemp[Main.learnArrayPointerTemp][1]=note[1];
				Main.learnArrayTemp[Main.learnArrayPointerTemp][2]=note[2];
				Main.learnArrayPointerTemp++;		
				System.out.println("learn array pointer temp = "+Main.learnArrayPointerTemp);
				
			}
		}
	}
}
